<?php

namespace app\admin\controller;

use app\common\model\Member as MemberModel;
use app\common\model\ManagerPassword as ManagerPasswordModel;
/**
 * 修改密码控制器
 * Class Index
 * @package app\index\controller
 */
class Managerpassword extends Base
{
    /**
     * [getIndex  获取个人中心数据]
     * @param
     * @return json
     * @author [C。]
     */
    public function index()
    {
        $param = input('param.');
        $this->getPageAndSize($param);
        $model = new ManagerPasswordModel;
        $mmodel = new MemberModel;
        $map = [];
        try {
            $map['mp.comid'] = $param['comid'];
            $map['mc.status'] = 1;
            $map['mp.states'] = 1;
            $field = 'mp.id,mp.tel,mp.pass,mp.mid';
            $count = $model->getcount($map);//满足条件的总数
            $allpage = intval(ceil($count / $this->size));//总页数
            $lists = $model->getlist($map, $this->from, $this->size, $field);
            foreach ($lists as &$v){
                $member = $mmodel->findData($v['tel'],'tel','tel,username,img');
                $v['tel'] = $member['tel'];
                $v['username'] = $member['username'];
                $v['img'] = $member['img'];
            }
        } catch (\Exception $e) {
            return admin_json(-1, '获取失败' . $e->getMessage());
        }
        return admin_json(1, '获取成功', [
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'lists' => $lists,  //列表数据
        ]);
    }
}